package com.lrd.snapshotorder.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {

    @Bean("orderProducerThreadPool")
    public ThreadPoolExecutor orderProducerThreadPool() {
        return new ThreadPoolExecutor(
                100,
                200,
                60L,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(200000),
                runnable -> new Thread(runnable, "JobTriggerHelper-fastTriggerPool" + runnable.hashCode()));
    }

    @Bean("orderVerifyThreadPool")
    public ThreadPoolExecutor orderVerifyThreadPool() {
        return new ThreadPoolExecutor(
                10,
                10,
                60L,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100),
                runnable -> new Thread(runnable, "JobTriggerHelper-fastTriggerPool" + runnable.hashCode()));
    }
}
